package com.lk.security.authorize;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @program: lk-security-parent
 * @description: 将所有的授权配置统一的管理起来
 * @author: Aspirin
 * @create: 2020-06-14 23:23
 */
@Component
public class CustomAuthorizeConfigurerManager implements AuthorizeConfigurerManager {
  @Autowired List<AuthorizeConfigurerProvider> authorizeConfigurerProviders;
  /**
   * 将一个个AuthorizeConfigurerProvider的实现类，传入配置的参数 ExpressionInterceptUrlRegistry
   *
   * @param config 授权对象
   */
  @Override
  public void configure(
      ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry config) {
    for (AuthorizeConfigurerProvider provider : authorizeConfigurerProviders) {
      provider.configure(config);
    }
  }
}
